package main

import (
	"errors"
)

func main() {
	var ret,err = Add(1,-1)
	if err ==nil {
		println("Add(1,2)=",ret)
	} else {
		println("error :",err.Error())
	}

	MultpArg(1,3,5,7,9)
	MultpArgs(1,3.14,5,7,9,"hello",true)

	var b = func(a,b int,z float64) bool{
		return a + b < int(z)
	}(1,1,3.14)

	println("ret ",b)
}

func Add(a int,b int)(ret int,err error)  {
	if a<0 || b<0{
		err = errors.New("not be <0")
		return
	}
	return a +b,nil
}

func MultpArg(args... int)  {
	for i,v := range args {
		println("arg ",i,v)
	}
}

func MultpArgs(args... interface{})  {
	for i,v := range args {
		switch v.(type) {
		case int:
			println("int ",v)
		case string:
			println("string ",v)
		default:
			println(v)
		}
		println("arg ",i,v)
	}
}
